package cn.itcast.day05.demo05;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayListStudent {
    public static void main(String[] args) {
        ArrayList<Student>list=new ArrayList<>();

        Scanner sc=new Scanner(System.in);


        Student one=new Student("1号",20);
        Student two=new Student("2号",21);
        Student three=new Student("3号",22);
        Student four=new Student("4号",23);

        Student t=new Student();
        System.out.println("输入小1姓名");
        t.setName(sc.nextLine());
        System.out.println("输入小a年龄");
        t.setAge(sc.nextInt());




        list.add(one);
        list.add(two);
        list.add(three);
        list.add(four);
        list.set(1,t);
        //遍历集合
        for (int i = 0; i < list.size(); i++) {
            Student st=list.get(i);
            System.out.println("姓名："+st.getName()+"年龄："+st.getAge());

        }
    }
}
